from pattern.circuit import Control


class entry(Control):

    DEFAULT_REPLY = ":%(servername)s 375 %(username)s\r\n:%(servername)s 372 %(username)s :- information.  Thank you for using freenode!\r\n:%(servername)s 376 %(username)s :End of /MOTD command.\r\n"

    def incoming(self, event):
        event.trail.username = event.data[0][0]
        event.trail.wfile.write(self.DEFAULT_REPLY \
                                % {'servername': "localhost",
                                   'username': event.trail.username})
        self.onEnter(event, event.trail.username)

    def onEnter(self, event, user):
        bridge = self.acquireInterface(event, "onEnter")
	if bridge is not None:
            bridge.push("enter", user)
